home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / CD32 / CD32_Support / examples / SA_Examples / cd / CDTest / verify.c < prev   
Encoding:
C/C++ Source or Header  |  1999-10-27  |  3.7 KB  |  207 lines

  1. /*
  2. **  cd.device Test
  3. **  Written by John J. Szucs
  4. **  Copyright © 1993-1999 Amiga, Inc.
  5. **  All Rights Reserved
  6. */
  7.  
  8. /*
  9. **  ANSI includes
  10. */
  11.  
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include <string.h>
  15. #include <math.h>
  16.  
  17. /*
  18. **  System includes
  19. */
  20.  
  21. #include <exec/types.h>
  22. #include <exec/io.h>
  23.  
  24. #include <dos/dos.h>
  25. #include <dos/dostags.h>
  26.  
  27. #include <devices/cd.h>
  28.  
  29. #include <rexx/rxslib.h>
  30. #include <rexx/storage.h>
  31. #include <rexx/errors.h>
  32.  
  33. #include <clib/exec_protos.h>
  34. #include <clib/dos_protos.h>
  35. #include <clib/rexxsyslib_protos.h>
  36. #include <clib/alib_protos.h>
  37.  
  38. /*
  39. **  Local includes
  40. */
  41.  
  42. #include "simplerexx.h"
  43. #include "cdtest.h"
  44.  
  45. /****** cd/byteVerify ******************************************
  46. *
  47. *   NAME
  48. *       byteVerify  -   verify byte pattern
  49. *
  50. *   SYNOPSIS
  51. *       pass=byteVerify(buffer,length,byte);
  52. *
  53. *       BOOL byteVerify(UBYTE *buffer,ULONG length,UBYTE byte);
  54. *
  55. *   FUNCTION
  56. *       Verify byte pattern.
  57. *
  58. *   INPUTS
  59. *       buffer      -   buffer to verify
  60. *       length      -   buffer length (bytes)
  61. *       byte        -   byte value to test against
  62. *
  63. *   RESULT
  64. *       pass        -   TRUE if pass; FALSE if error
  65. *
  66. *   EXAMPLE
  67. *
  68. *   NOTES
  69. *
  70. *   BUGS
  71. *
  72. *   SEE ALSO
  73. *
  74. ******************************************************************************
  75. *
  76. */
  77.  
  78. BOOL byteVerify(UBYTE *buffer,ULONG length,UBYTE byte)
  79. {
  80.  
  81.     UBYTE *thisByte;
  82.     ULONG loop;
  83.  
  84.     /* Verify byte pattern */
  85.     for (thisByte=buffer,loop=0;loop<length;thisByte++,loop++) {
  86.         /* If no match ... */
  87.         if (*thisByte!=byte) {
  88.             /* Fail */
  89.             return(FALSE);
  90.         }
  91.     }
  92.  
  93.     /* Pass */
  94.     return(TRUE);
  95.  
  96. }
  97.  
  98. /****** cd/wordVerify ******************************************
  99. *
  100. *   NAME
  101. *       wordVerify  -   verify word pattern
  102. *
  103. *   SYNOPSIS
  104. *       pass=wordVerify(buffer,length,word);
  105. *
  106. *       BOOL wordVerify(UBYTE *buffer,ULONG length,UWORD word);
  107. *
  108. *   FUNCTION
  109. *       Verify word pattern.
  110. *
  111. *   INPUTS
  112. *       buffer      -   buffer to verify
  113. *       length      -   buffer length (bytes)
  114. *       byte        -   word value to test against
  115. *
  116. *   RESULT
  117. *       pass        -   TRUE if pass; FALSE if error
  118. *
  119. *   EXAMPLE
  120. *
  121. *   NOTES
  122. *
  123. *   BUGS
  124. *
  125. *   SEE ALSO
  126. *
  127. ******************************************************************************
  128. *
  129. */
  130.  
  131. BOOL wordVerify(UBYTE *buffer,ULONG length,UWORD word)
  132. {
  133.  
  134.     UWORD *thisWord;
  135.     ULONG loop;
  136.  
  137.     /* Verify byte pattern */
  138.     for (thisWord=(UWORD *) buffer,loop=0;
  139.          loop<length/sizeof(word);
  140.          thisWord++,loop++) {
  141.         /* If no match ... */
  142.         if (*thisWord!=word) {
  143.             /* Fail */
  144.             return(FALSE);
  145.         }
  146.     }
  147.  
  148.     /* Pass */
  149.     return(TRUE);
  150.  
  151. }
  152.  
  153. /****** cd/offsetVerify ******************************************
  154. *
  155. *   NAME
  156. *       offsetVerify  -   verify offset pattern
  157. *
  158. *   SYNOPSIS
  159. *       pass=offsetVerify(buffer,length,start);
  160. *
  161. *       BOOL byteVerify(UBYTE *buffer,ULONG length,ULONG start);
  162. *
  163. *   FUNCTION
  164. *       Verify word pattern.
  165. *
  166. *   INPUTS
  167. *       buffer      -   buffer to verify
  168. *       length      -   buffer length (bytes)
  169. *       start       -   starting value of pattern
  170. *
  171. *   RESULT
  172. *       pass        -   TRUE if pass; FALSE if error
  173. *
  174. *   EXAMPLE
  175. *
  176. *   NOTES
  177. *
  178. *   BUGS
  179. *
  180. *   SEE ALSO
  181. *
  182. ******************************************************************************
  183. *
  184. */
  185.  
  186. BOOL offsetVerify(UBYTE *buffer,ULONG length,ULONG start)
  187. {
  188.  
  189.     ULONG *thisOffset;
  190.     ULONG loop, value;
  191.  
  192.     /* Verify offset pattern */
  193.     for (thisOffset=(ULONG *) buffer,loop=0,value=start;
  194.          loop<length/sizeof(*thisOffset);
  195.          thisOffset++,loop++,value+=sizeof(*thisOffset)) {
  196.         /* If no match ... */
  197.         if (*thisOffset!=value) {
  198.             /* Fail */
  199.             return(FALSE);
  200.         }
  201.     }
  202.  
  203.     /* Pass */
  204.     return(TRUE);
  205.  
  206. }
  207.